/*
 * InversePoland.h
 *
 *  Created on: 2013-5-2
 *      Author: xkaying
 */

#ifndef INVERSEPOLAND_H_
#define INVERSEPOLAND_H_

#include "stack.h"
#include "list.h"
#include "token.h"

//逆波兰表达式的生成
typedef int (*InversePolandEach)(Stack *poutput,Token *ptoken,Stack *pstore);

/* 单次处理逆波兰表达式的样板
 * int InversePolandDeclare(Stack *poutput,Token *ptoken,Stack *pstore)
 * {
 * 		assert(poutput);
 * 		assert(ptoken);
 * 		assert(pstore);
 * 		switch(ptoken->type){
 * 		case TokenType_Variable:
 * 		case TokenType_Value:
 * 		case TokenType_String:{
 * 			StackPush(poutput,ptoken);
 * 			return 1;
 * 			}
 * 		case TokenType_left_kuohao:{
 * 			StackPush(pstore,ptoken);
 * 			return 1;
 * 			}
 * 		case TokenType_right_kuohao:{
 * 			free(ptoken);//删除当前括号,并寻找匹配的括号
 * 			ptoken=(Token*)StackPop(pstore);
 * 			while(ptoken){
 * 				if(ptoken->type==TokenType_left_kuohao){
 * 					free(ptoken);
 * 					return 1;
 * 				}
 * 				StackPush(ptoken);
 * 				ptoken=(Token*)StackPop(pstore);
 * 			}
 * 			return 0;
 * 			}
 * 		case TokenType_declareor:{
 * 			while(1){
 * 			if(cmp(TokenType_declareor,StackData(pstore)){
 * 				//如果>pstack data
 * 				StackPush(pstore,ptoken);
 * 				return;
 * 			}else{ *
 *
 * 				StackPush(ptoken,StackPop(pstore);)
 * 			}}
 * 		}
 * 		if(token->type==open){
		if(token->type>estack.top.type){
			estack.push.
		}else{
			estack.pop
			addtoken;
		}
	}
 *
 *
 */

Stack *InversePoland(List *ptokenlist,InversePolandEach each);


#endif /* INVERSEPOLAND_H_ */
